package com.shujia.day14;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Code09InputStreamReader {
    public static void main(String[] args) throws IOException {
        FileInputStream fileInputStream = new FileInputStream("data/f.txt");
        InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream,"GBK");

//        int read = inputStreamReader.read(); // 读取到的是单个的字符
//        System.out.println(read);
        char[] chars = new char[6];
//        int read = inputStreamReader.read(chars);  // 通过传入一个字符数组可以读取到文件中的数据
//        System.out.println(read);
//        System.out.println(Arrays.toString(chars));

        int read = 0;
        while ((read = inputStreamReader.read(chars)) != -1) {
            System.out.println(Arrays.toString(chars));
        }

        inputStreamReader.close();

    }
}
